    /****************************** 访客记录开始 **************************************/

    function GetQueryString(name)
    {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }

    var activity_id = GetQueryString('activity_id')
    var https = "https://collect.topeffects.cn/"

    function agent() {
        var arr = []
        var userAgentInfo = navigator.userAgent;
        var Agents = ["Android", "iPhone",
            "SymbianOS", "Windows Phone",
            "iPad", "iPod"];
        var flag = true;
        for (var v = 0; v < Agents.length; v++) {
            if (userAgentInfo.indexOf(Agents[v]) > 0) {
                flag = false;
                break;
            }
        }

        //获取终端平台
        var start = userAgentInfo.indexOf('(')
        var end = userAgentInfo.indexOf(')')
        var str = userAgentInfo.slice(start +1,end)

        arr[0] = flag
        arr[1] = str
        return arr;
    }
    var fromurl = document.referrer;
    var agent = agent();
    var invest_draw = 1;
    var uv = localStorage.getItem('uv{{ $activity_id }}')

    // 用户跳转页面时
    $(document).ready(function(){

        var url = https + "/api_get_data";

        $.getJSON(url, function(data){

            var load_time = new Date().getTime()
            city = data.Isp = data.province + '省' + data.city + '市'
            ip = data.Ip

            terminal_type = agent[0] ? '1' : '2'; // 终端类型
            var terminal_edition = agent[1]; // 终端版本

            var src = "{{ Input::get('src') }}"; //来源

            if( localStorage.getItem('visitorid{{ $activity_id }}') ) {

                // 避免重复记录
                timestamp = Date.parse(new Date()) / 1000;

                // 记录下插入时间
                localStorage.setItem('record_time', timestamp)

                // 如果已经登记过，直接插入访客记录表
                var visitorid = localStorage.getItem('visitorid{{ $activity_id }}')
                var url = https + 'api_visitor_record';

                var data = {
                    '_token': '{{csrf_token()}}',
                    ip: ip,
                    activity_id: activity_id,
                    load_time: load_time,
                    fromurl: fromurl,
                    visitorid: visitorid,
                    src: src,
                    city: city,
                    uv : uv
                };
                $.post(url, data, function (e) {

                    // 访客记录
                    sessionStorage.setItem('recordid{{ $activity_id }}', e)


                    // 已经登记过了uv，修改
                    localStorage.setItem('uv{{ $activity_id }}', 2)

                }, 'json')

            } else {

                // 如果没登记过，先插入用户详细信息，获取到id后，再插入到访客记录表
                var url = https + 'api_visitor_info';
                var data = {'_token':'{{csrf_token()}}', invest_draw : invest_draw, ip : ip, activity_id : activity_id, terminal_type : terminal_type, terminal_edition : terminal_edition, src : src, city : city, load_time : load_time, fromurl : fromurl};

                $.post(url, data, function (e){

                    // 访客记录
                    localStorage.setItem('visitorid{{ $activity_id }}',e.id)
                    sessionStorage.setItem('recordid{{ $activity_id }}',e.v_id)

                    // 已经登记过了uv，修改
                    localStorage.setItem('uv{{ $activity_id }}', 2)

                },'json')
            }

        });
    });

    // 点击我知道了隐藏按钮提示遮罩层
    $('.share_isee').click(function (){
        $('.share').hide()
    })

    /******************************** 访客记录结束 ************************************/